const express = require('express');
const router = express.Router();
const multer = require('multer');
const booksController = require('../controller/BooksController');

// 定义上传的目录
let upload = multer({ dest: 'uploads/' });

router.get('/getPage', booksController.getPage);
router.delete('/delBook/:id', booksController.delBook);
router.delete('/delpicture', booksController.delpicture);
router.get('/search', booksController.search);
router.get('/getAllType', booksController.getAllType);
router.post('/addBook', booksController.addBook);
router.post('/addpicture', upload.single('cover'), booksController.addpicture);
router.get('/getOneBook', booksController.getOneBook);
router.put('/editOneBook/:id', booksController.editOneBook);
router.post(
  '/editpicture',
  upload.single('cover2'),
  booksController.editpicture
);
module.exports = router;
